package org.future.esb;

import java.util.ArrayList;
import java.util.List;

/**
 *@date   2010-4-11 下午09:20:38
 *@author dycc
 *@file   org.future.esb.EsbModel.java
 */
public class MuleConf {
	public static void main(String[] args) {
		MuleConf t = new MuleConf();
		t.getJmsConnectors().add(new JmsConnector());
		System.out.println(t.toString());
    }
	
	private String declaration = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
	private String root = "";
	private List<JmsConnector> jmsConnectors = new ArrayList<JmsConnector>();
	private Model model = new Model();
	private String tail = "</mule>";	
	/**
	 * toString
	 */
	public String toString(){
		StringBuffer sb = new StringBuffer();
		sb.append(getDeclaration());
		sb.append("\r\n");
		sb.append(getRoot());
		sb.append("\r\n");
		// add jms connector
		for(int i=0;i<jmsConnectors.size();i++){
			sb.append(jmsConnectors.get(i));
			sb.append("\r\n");
		}
		// add model
		sb.append(getModel());
		sb.append("\r\n");
		// 
		sb.append(getTail());
		sb.append("\r\n");
		return sb.toString();
	}
	
	public String getDeclaration() {		
	    return declaration;
    }
	public void setDeclaration(String declaration) {
	    this.declaration = declaration;
    }
	
	public String getRoot() {
		if("".equals(root)){
			root = "<mule"
				 + " xmlns=\"http://www.mulesource.org/schema/mule/core\"\r\n"
				 + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\r\n"
				 + " xmlns:spring=\"http://www.springframework.org/schema/beans\"\r\n"
				 + " xmlns:context=\"http://www.springframework.org/schema/context\"\r\n"
				 + " xmlns:http=\"http://www.mulesource.org/schema/mule/http\"\r\n"
				 + " xmlns:axis=\"http://www.mulesource.org/schema/mule/axis\"\r\n"
				 + " xmlns:jms=\"http://www.mulesource.org/schema/mule/jms\"\r\n"
				 + " xmlns:vm=\"http://www.mulesource.org/schema/mule/vm\"\r\n"
				 + " xmlns:xm=\"http://www.mulesource.org/schema/mule/xml\"\r\n"
				 + " xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\"\r\n"
				 + ">";
		}
	    return root;
    }
	public void setRoot(String root) {
	    this.root = root;
    }
	
	public List<JmsConnector> getJmsConnectors() {
	    return jmsConnectors;
    }
	public void setJmsConnectors(List<JmsConnector> jmsConnectors) {
	    this.jmsConnectors = jmsConnectors;
    }
	
	public Model getModel() {
	    return model;
    }
	public void setModel(Model model) {
	    this.model = model;
    }
	
	public String getTail() {		
	    return tail;
    }
	public void setTail(String tail) {
	    this.tail = tail;
    }
}
